package com.neutech.solar.client;

import com.neutech.solar.entity.Background;
import com.neutech.solar.entity.MyFrame;
import com.neutech.solar.entity.Planet;
import com.neutech.solar.entity.Sun;

import java.awt.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Random;

public class SolarSystemClient extends MyFrame {

    public Background bg = new Background("bg.jpg");
    public Sun sun = new Sun();
    Planet Mercury = new Planet(sun,"Mercury",0.387,0.2056,88,"水星");
    Planet Venus = new Planet(sun,"Venus",0.72,0.068,225,"金星");
    Planet Earth = new Planet(sun,"Earth",1,0.0167,365,"地球");
   Planet Mars = new Planet(sun,"Mars",1.52,0.0934,687,"火星");
    Planet Jupiter = new Planet(sun,"Jupiter",5.2,0.0489,4330,"木星");
    Planet Saturn = new Planet(sun,"Saturn",9.54,0.0557,10832,"土星");
    Planet Uranus = new Planet(sun,"Uranus",19.218,0.0444,30777,"天王星");
    Planet Neptune = new Planet(sun,"qiqihead",30.06,0.0112,60328,"海王星");
    List<Planet> planets = new ArrayList<>();
    Random r = new Random();
    {
        for (int i = 0; i < 1000; i++) {
            double AU = r.nextDouble()*2+2.0;
            double e = r.nextDouble();
            int T =r.nextInt(3300) + 700;
           Planet smallPlanet =new Planet(sun,"smallPlanet",AU,0.0,T,"",true);
           planets.add(smallPlanet);

        }

    }

    public SolarSystemClient(){
        super.init("太阳系八行星运行系统");
    }

    @Override
    public void paint(Graphics g) {
        bg.draw(g);
        sun.draw(g);
        Mercury.draw(g);
        Venus.draw(g);
        Earth.draw(g);
        Mars.draw(g);
        //小行星带
        for(Planet smallPlanet :planets){
            smallPlanet.draw(g);
        }
        Jupiter.draw(g);
        Saturn.draw(g);
        Uranus.draw(g);
        Neptune.draw(g);



    }

    public static void main(String[] args) {
        new SolarSystemClient();
    }
}
